include("autorun/shared.lua")

if CUR == nil then
CUR = "$"
end

local function HUDPaint()
if (SERVER) then return end

	local ply = LocalPlayer()
	
	surface.CreateFont( "coolvetica", 16, 500, true, false, "text" )
	
	if ( !ValidEntity( ply ) ) then return end

local hptxt=surface.GetTextureID("gui/silkicons/pill")
local montxt=surface.GetTextureID("gui/silkicons/information")

	surface.SetDrawColor(255,255, 255, 255)
	surface.DrawRect(0, 0, ScrW(), 16)


surface.SetTexture(hptxt)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(0,0,16,16)

surface.SetTexture(montxt)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(120,0,16,16)
	
	
	
	local colortouse = Color(40, 40, 40, 255)
	
	draw.DrawText("Cash: " .. CUR .. ply:GetNetworkedInt("money"), "text", 136, 0, colortouse, TEXT_ALIGN_LEFT)
	draw.DrawText("HP: " .. ply:Health(), "text", 16, 0, colortouse, TEXT_ALIGN_LEFT)
	local datetime = os.date("%H:%M:%S - %d/%m/%Y")
	draw.DrawText("Time: " .. tostring(datetime), "text", 300, 0, colortouse, TEXT_ALIGN_LEFT)
end
hook.Add( "HUDPaint", "MoneyMod.HUDPaint", HUDPaint )

function ShowPlayerMenu()
local ply = LocalPlayer()
   local trace = ply:GetEyeTrace()
   local hitpos = trace.HitPos
   local hitent = trace.Entity
   local playerid
   //hitent = ply // temp debugging
   if hitent == nill then return end
if hitent:IsPlayer( ) then
  playerid = hitent:EntIndex()
  local DermaPanel = vgui.Create( "DFrame" )
  DermaPanel:SetPos( 50, 50 )
  DermaPanel:SetSize( 300, 100 )
  DermaPanel:SetTitle( "Pay " .. hitent:GetName())
  DermaPanel:SetVisible( true )
  DermaPanel:SetDraggable( true )
  DermaPanel:ShowCloseButton( true )
  DermaPanel:MakePopup()
  
  local TestingPanel = vgui.Create( "DPanel", DermaPanel )
  TestingPanel:SetPos( 2, 24) // 10,26
  TestingPanel:SetSize( 296, 74 )
  TestingPanel.Paint = function() // Paint function
	surface.SetDrawColor( 50, 50, 50, 255 ) // Set our rect color below us; we do this so you can see items added to this panel
	surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) // Draw the rect
  end
  
  myText = vgui.Create("DTextEntry", TestingPanel)
  myText:SetText("100")
  myText:SetSize(180,20)
  myText:SetPos(20,10)
  //The following has been changed from "myText:GetText()" to "myText:GetValue()"
  //myText.OnEnter = function() Msg("Text Entered: " .. myText:GetValue() .. "\n") end 
  
  local DermaButton = vgui.Create( "DButton", TestingPanel )
  DermaButton:SetText( "PAY" )
  DermaButton:SetPos( 20, 30 )
  DermaButton:SetSize( 180,20 )
  DermaButton.DoClick = function ()
	Msg("pay " .. playerid .. " " .. myText:GetValue())
	RunConsoleCommand( "pay", playerid, myText:GetValue() )
	DermaPanel:Close()
  end 
   
   end 

end
concommand.Add("showplayermenu",ShowPlayerMenu)